<template>
    <div class="header-box">
        <div class="l-content">
            <!-- 按钮 -->
            <el-button @click="handelCollapse()" class="tools-btn">
                <el-icon>
                    <Grid />
                </el-icon>
            </el-button>
            <!-- 面包屑 -->

            <el-breadcrumb separator="/" class="bread-box">
                <!-- 首页始终存在 -->
                <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
                <el-breadcrumb-item v-if="current" :to="current.path">
                    {{ current.labal }}
                </el-breadcrumb-item>
            </el-breadcrumb>

        </div>
        <div class="r-content">
            <!-- 下拉框 -->
            <el-dropdown>
                <span class="el-dropdown-link">
                    <img class="user" :src="getImgSrc('user')" alt="用户">
                </span>
                <template #dropdown>
                    <el-dropdown-menu>
                        <el-dropdown-item>Action 1</el-dropdown-item>
                        <el-dropdown-item>Action 2</el-dropdown-item>
                    </el-dropdown-menu>
                </template>
            </el-dropdown>


        </div>
    </div>


</template>
<script setup>
// 引入仓库/创建仓库
import { computed } from 'vue';
import { useAside } from '../store/index.js';
const main = useAside()

// 
const handelCollapse = () => {
    main.updateIsCollapse()
}

// 图片的动态加载
const getImgSrc = (val) => {
    return new URL(`../assets/${val}.jpg`, import.meta.url).href
}
// 侦听仓库的currentMenu变化
const current =computed(()=>{
    return main.currentMenu
})

</script>

<style lang="less">
.header-box {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    .l-content{
        display: flex;
        align-items: center;
        justify-content: center;
        .tools-btn {
        margin-right: 10px;
       }
    }

}

.user {
    width: 30px;
    height: 30px;
    border-radius: 50%;
}
</style>